﻿using System;
using System.Collections.Generic;

class MostFrequentNumber
{
    static void Main()
    {
        Console.WriteLine("Enter the number of elements:");
        int numberOfElements = int.Parse(Console.ReadLine());
        int[] arrayOfInts = new int[numberOfElements];
        int counter = 1;
        int mostFrequent = 0;
        for (int index = 0; index < numberOfElements; index++)
        {
            Console.WriteLine("Enter element {0}",index);
            arrayOfInts[index] = int.Parse(Console.ReadLine());
        }

        for (int i = 0; i < numberOfElements - 1; i++)
        {
            int tempCounter = 1;
            for (int j = i + 1; j < numberOfElements; j++)
            {
                if (arrayOfInts[i] == arrayOfInts[j])
                {
                    tempCounter++;
                }
                if (tempCounter > counter)
                {
                    counter = tempCounter;
                    mostFrequent = arrayOfInts[i];
                }
            }
                
        }
        
        Console.WriteLine("Most frequent element is {0} ({1} times)", mostFrequent, counter);
    }
}

